package com.fish.common.jms;

import java.io.Serializable;

public class Message implements Serializable{

	private static final long serialVersionUID = -1118236567096207803L;
	
	private Long objectId;
	private String objectType;
	private String eventType;
	private String addition;	//无特定，可以灵活跟随信息
	
	private Message() {}
	
	public Message(Long objectId, String objectType, String eventType) {
		this.objectId = objectId;
		this.objectType = objectType;
		this.eventType = eventType;
	}
	
	public Long getObjectId() {
		return objectId;
	}
	public void setObjectId(Long objectId) {
		this.objectId = objectId;
	}
	public String getObjectType() {
		return objectType;
	}
	public void setObjectType(String objectType) {
		this.objectType = objectType;
	}
	public String getEventType() {
		return eventType;
	}
	public void setEventType(String eventType) {
		this.eventType = eventType;
	}
	public boolean isNullAddition() {
		return addition==null;
	}
	public String getAddition() {
		return addition;
	}
	public void setAddition(String addition) {
		this.addition = addition;
	}
	
	public boolean equals(Object obj) {
		if (obj instanceof Message) {
			Message cc = (Message)obj;
			return objectId.equals(cc.getObjectId()) && eventType.equals(cc.getEventType());
		}else{
			return false;
		}
	}

	@Override
	public int hashCode() {
		return toString().hashCode();
	}

	@Override
	public String toString() {
		return "Message_" + objectType+ "_" + objectId + "_" + eventType +(this.addition!=null?"_"+this.addition:"");
	}

}
